declare var tt: any;
import { _decorator, Component, Node, resources, sys, Tween, tween } from 'cc';
import * as fgui from "fairygui-cc";
import SdkTool from '../../../../Core/Sdk/SdkTool';
import AbstractUIWindow from '../../window/AbstractUIWindow';
import UICore from '../../../../Core/Res/UICore';
import SceneManager from '../SceneManager';
import GameScenes from '../GameScenes';
import EventMgr from '../../../../Core/Event/EventMgr';
import TimerMgr from '../../../../Core/Timer/TimerMgr';
import ModuleWindow from '../../window/ModuleWindow';
import WindowObject from '../../window/WindowObject';
import { ExternalGLoader } from '../../../../Core/Layer/ExternalGLoader';
export class TtStartView extends AbstractUIWindow {
    private bg_full: ExternalGLoader;
    private progress: fgui.GProgressBar;
    protected getResList(): Array<string> {
        return ["Start"];
    }
    protected onInit(): void {
        this._view = UICore.createObject("Start", "TtStartView").asCom;
    }
    protected onShow(): void {
        this.bg_full.url = `bg2.jpg`;
        EventMgr.on(`event_RespEnterLobby`, this.enterGame, this);
        EventMgr.on(`serverError`, this.serverError);
        SdkTool.ins.sdk.login();
    }
    private serverError(): void {
        ModuleWindow.ins.openWindow(WindowObject.ins.AlertWindow, `服务器正在维护中，请稍后再试`);
    }
    private enterGame(): void {
        this.progress.visible = true;
        this.progress.value = 0;
        this.progress.max = 100;
        let res = [
            "UI/Main",  //描述文件
            "UI/Main_atlas0", //纹理集
            "UI/Plane",  //描述文件
            "UI/Plane_atlas0", //纹理集
            "UI/Common",  //描述文件
            "UI/Common_atlas0", //纹理集
            "UI/Font",  //描述文件
            "UI/Font_atlas0", //纹理集
        ];
        resources.load(res, (finsh, toal, item) => {
            this.progress.max = toal;
            this.progress.value = finsh;
        }, (err, assets) => {
            UICore.addPackage(`Main`);
            UICore.addPackage(`Plane`);
            UICore.addPackage(`Common`);
            UICore.addPackage(`Font`);
            SceneManager.ins.enterScene(GameScenes.main);
        });
    }
}


